import 'package:flutter/material.dart';


class CheckBoxDemo extends StatefulWidget {
  @override
  _CheckBoxDemoState createState() => _CheckBoxDemoState();
}

class _CheckBoxDemoState extends State<CheckBoxDemo> {
  bool checkBoxState = true;
  int _radGroupA = 0;
  double _sliderItemA = 0.0;
  void  _handleRadioValeChanged(int value){
        setState(() {
          _radGroupA = value;
        });
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title:Text('CheckBoxDemo'),
          elevation: 0.0,
        ),
        body: Container(
         padding: EdgeInsets.all(100),
         child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
           Slider(
             value: _sliderItemA, 
             onChanged: (value){
                 setState((){
                   _sliderItemA = value;
                 });
               },
             activeColor: Theme.of(context).accentColor,
             inactiveColor: Theme.of(context).accentColor.withOpacity(0.3),
             min: 0.0,
             max: 10.0,
             divisions: 10,
             label: '${_sliderItemA.toInt()}',
               
             ),

           SizedBox(height:100),
           
            SwitchListTile(
              value: checkBoxState, 
              onChanged: (value){
                 setState((){
                   checkBoxState = value;
                 });
               },
                title: Text('Option B'),
                subtitle: Text('Description'),
                secondary: Icon(checkBoxState ? Icons.visibility:Icons.visibility_off),
                selected: checkBoxState,

              ),


             Text(checkBoxState ? '😁':'😢'),
             Switch(
               value: checkBoxState, 
               onChanged: (value){
                 setState((){
                   checkBoxState = value;
                 });
               }
               
               ),


            Text('$_radGroupA'),
            SizedBox(height:10),
             RadioListTile(
                  value: 0,
                   groupValue: _radGroupA, 
                   onChanged: _handleRadioValeChanged,
                   title: Text('Option A'),
                   subtitle: Text('Description'),
                   secondary: Icon(Icons.filter_1),
                   selected: _radGroupA == 0,
                ),
                 RadioListTile(
                  value: 1,
                   groupValue: _radGroupA, 
                   onChanged: _handleRadioValeChanged,
                   title: Text('Option B'),
                   subtitle: Text('Description'),
                   secondary: Icon(Icons.filter_1),
                   selected: _radGroupA == 1,
                ),

            Row(
             mainAxisAlignment: MainAxisAlignment.center,
             children: <Widget>[
                // Radio(
                //   value: 0, 
                //   groupValue: _radGroupA, 
                //   onChanged: _handleRadioValeChanged,
                //   activeColor: Colors.red,
                //   ),
                //   Radio(
                //   value: 1, 
                //   groupValue: _radGroupA, 
                //   onChanged: _handleRadioValeChanged,
                //   activeColor: Colors.red,
                //   )
             ],
            )
          ],
         ),
        ),
    );
  }
}


// class  CheckboxListTileDemo  extends StatelessWidget {
//   bool checkBoxState = true;
//   @override
//   Widget build(BuildContext context) {
//     return Container(
//          padding: EdgeInsets.all(100),
//          child: Column(
//          mainAxisAlignment: MainAxisAlignment.center,
//           children: <Widget>[
//             CheckboxListTile(
//               value: checkBoxState, 
//               onChanged: (value){
//                 setState(() {
//                   checkBoxState = value;
//                 });
//               },
//               title: Text('Check Item A'),
//               subtitle: Text('Description'),
//               secondary: Icon(Icons.bookmark),
//               selected: checkBoxState,
//               )
//             //  Checkbox(
//             //     activeColor: Colors.black,
//             //     checkColor: Colors.red,
//             //     value: checkBoxState,
//             //     onChanged: (value){
//             //        setState(() {
//             //          checkBoxState = value;
//             //        });
//             //      }
//             //     )

//           ],
//          ),
//         );
//   }
// }